<?php
/*
 * @Date: 2024-04-12 21:26:00
 * @LastEditTime: 2024-04-13 19:31:14
 * @Description:
 */
include 'db.php';
if (!$conn) {
    die("连接失败: " . mysqli_connect_error());
}

// 执行查询
// $sql = "SELECT * FROM daiban"; 只输出status等于1的
$sql = "SELECT * FROM daiban WHERE status = 1";
$result = mysqli_query($conn, $sql);

$data = array();

// 处理查询结果
if ($result && mysqli_num_rows($result) > 0) {
    while ($row = mysqli_fetch_assoc($result)) {
        unset($row['time']);
        unset($row['status']);
        $data[] = $row;
        // 数量
        $count = count($data);
    }
    $todo = array(
        "code" => 200,
        "count" => $count,
        "msg" => "获取成功",
        "data" => $data
    );
    header('Content-Type: application/json; charset=utf-8');
    echo json_encode($todo, JSON_UNESCAPED_UNICODE);
} else {
    $todo = array(
        "code" => 404,
        "msg" => "没有数据",
    );
    header('Content-Type: application/json; charset=utf-8');
    echo json_encode($todo, JSON_UNESCAPED_UNICODE);
}

// 关闭数据库连接
mysqli_close($conn);



?>

